//
//  FoundOrderViewController.m
//  beautyAccompany
//
//  Created by xiaocankeji on 15/11/25.
//  Copyright © 2015年 xiaocankeji. All rights reserved.
//

#import "FoundOrderViewController.h"
#import "CycleScrollView.h"
#import "PriceSelectView.h"
#define kTopicScrollViewHeight (230*DeviceWidth/375)
#define kHeaderViewHeight (kTopicScrollViewHeight+80)
#define kBottomViewHeight 50

@interface FoundOrderViewController ()
@property (nonatomic, strong) NSArray *titleArr;
@property (nonatomic, strong) NSArray *iconArr;
@property (nonatomic, strong) UIView *headerView;//
@property (nonatomic, strong) CycleScrollView *topicScrollView;//滑动的专辑
@property (nonatomic, strong) NSMutableArray *topicViews;//
@property (nonatomic, strong) PriceSelectView *priceSelectView;//选择级别
@property (nonatomic, strong) UIView *bottomView;//底部view


@end

@implementation FoundOrderViewController

- (NSMutableArray *)topicViews
{
    if (nil == _topicViews) {
        _topicViews = [NSMutableArray array];
    }
    return _topicViews;
}
- (void)viewDidLoad {
    [super viewDidLoad];
   self.view.backgroundColor = APPCOLORBACKGROUNDCOLOR(1);
    self.title = self.category.title;
    self.tableView.frame  = CGRectMake(0, 0, DeviceWidth, DeviceHeight - kBottomViewHeight);
    if ([self.category.title isEqualToString:@"一起运动"]) {
        _titleArr = @[@"时间",@"时长",@"项目",@"地点",@"备注",@"提示"];
        _iconArr = @[@"时间icon",@"时长icon",@"项目icon",@"地点icon",@"备注icon",@"提示"];
    }else if(self.category.type == 1){
        //线上
        _titleArr = @[@"时间",@"时长",@"地点",@"备注",@"提示"];
        _iconArr = @[@"时间icon",@"时长icon",@"地点icon",@"备注icon",@"提示"];
    }else{
        //线下
        _titleArr = @[@"时间",@"时长",@"提示"];
        _iconArr = @[@"时间icon",@"时长icon",@"提示"];
    }
    
    _headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, DeviceWidth, kHeaderViewHeight)];
    _headerView.backgroundColor = APPCOLORBACKGROUNDCOLOR(1);
    
    [self addHeaderViewSubview];
    self.tableView.tableHeaderView = _headerView;
    
    [self addBottomView];
    
    // Do any additional setup after loading the view.
}
//给headerView 上添加view
- (void)addHeaderViewSubview
{
    _topicScrollView = [[CycleScrollView alloc] initWithFrame:CGRectMake(0, 0, DeviceWidth, kTopicScrollViewHeight) animationDuration:5];
    _topicScrollView.backgroundColor = [UIColor whiteColor];
    [_headerView addSubview:_topicScrollView];
    [self setTopicContent];
    
    _priceSelectView = [[PriceSelectView alloc] init];
    _priceSelectView.frame = CGRectMake(0, kTopicScrollViewHeight, DeviceWidth, 75);
    _priceSelectView.category = self.category;
    [_headerView addSubview:_priceSelectView];
    
    
    
}
- (void)addBottomView
{
    
}
#pragma mark 设置专辑内容视图和点击事件
- (void)setTopicContent
{
    [self.topicViews removeAllObjects];
    
    
    for (int i = 0; i<4; i++) {
        CGFloat h = kTopicScrollViewHeight;
        UIImageView *topicImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, DeviceWidth, h)];
        [topicImageView setContentMode:UIViewContentModeScaleAspectFill];
        topicImageView.image = [UIImage imageNamed:@"背景"];
        
        [self.topicViews addObject:topicImageView];
    }
    [self setTopicContentViews];
    
}
- (void)setTopicContentViews
{
    __weak __typeof(self) weakSelf = self;
    self.topicScrollView.fetchContentViewAtIndex = ^UIView *(NSInteger pageIndex){
        
        if (pageIndex > weakSelf.topicViews.count) {
            return weakSelf.topicViews[0];
        }else{
            return weakSelf.topicViews[pageIndex];
        }
    };
    //设置个数
    self.topicScrollView.totalPagesCount = ^NSInteger(void){
        return [weakSelf.topicViews count];
    };
    //设置点击事件
    self.topicScrollView.TapActionBlock = ^(NSInteger pageIndex){
        [HUD Prompt:[NSString stringWithFormat:@"点击第%ld个",pageIndex+1]];
    };
    
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _titleArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    cell.textLabel.text = _titleArr[indexPath.row];
    return cell;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
